import React from 'react';
import { WeaTop, WeaLeftRightLayout, WeaRightMenu,WeaLocaleProvider } from 'ecCom';
import TaskTypeList from './TaskTypeList';
import TaskListRight from './TaskList';
import { observer, inject } from 'mobx-react';
import './index.less';
const getLabel = WeaLocaleProvider.getLabel;

@inject('edcTaskListStore')
@observer
export default class TaskList extends React.Component {
    componentDidMount() {
        const { edcTaskListStore: store } = this.props;
        store.init();
    }
    componentWillReceiveProps(nextProps) {
        const { location: { key } } = this.props;
        const { location: { key: nextKey }, edcTaskListStore: store } = nextProps;
        if (key !== nextKey) {
            store.init();
        }
    }
    render() {
        const { edcTaskListStore: store, location: { query: params } } = this.props;
        const menu = [{
            key: '1',
            icon: <i className='icon-coms-search' />,
            content: getLabel(388113,'搜索'),
            onClick: store.search,
        },]
        return (
            <WeaRightMenu datas={menu} >
                <WeaTop
                    title={getLabel('502834','我的填报任务')}
                    iconBgcolor="#1a57a0"
                    icon={<i className="icon-coms02-Data-center" />}
                    showDropIcon={true}
                    dropMenuDatas={menu}
                    loading={store.tableStore.loading}
                >
                    <WeaLeftRightLayout
                        leftWidth={300}
                        leftCom={<TaskTypeList store={store} />}
                    >
                        <TaskListRight store={store} params={params} />
                    </WeaLeftRightLayout>
                </WeaTop>
            </WeaRightMenu>
        )
    }
}